package cn.xie.blog.serverutil.constant.jwt;

import io.jsonwebtoken.SignatureAlgorithm;

import java.security.SecureRandom;
import java.time.Instant;
import java.util.Date;

/**
 * @author: xiaoxie
 * create: 2025-04-25 10:31
 * @BelongsProject: blog-parent
 * @BelongsPackage: cn.xie.blog.serverutil.constant
 * description: Jwt常量类
 */
public class JwtContants {
    // 过期时间（一小时）
    public static final long EXPIRE_TIME_IN_HOUR = 1;
    public static final long EXPIRE_TIME_IN_MILLIS = EXPIRE_TIME_IN_HOUR * 60 * 60 * 1000;
    public static final SignatureAlgorithm ALGORITHM = SignatureAlgorithm.HS256;
    // 主题
    public static final String SUBJECT = "user-login";
    // 签发者
    public static final String ISSUER = "AuthCenterApplication";
    public static final String SECRET = "xieK8q7Q3lZ6v9W2f5j1C4x7V0n8p2R1s9T4b6Y2h3M5w1G0e5";
    public static final String TOKEN_PREFIX = "jwt:token:";
    public static final String BLACKLIST_PREFIX = "jwt:blacklist:";
    public static final String REFRESH_TOKEN_PREFIX = "jwt:refresh_token:";
    public static final String CLAIM_KEY_USER = "username";

    // 获取过期时间的 Date 对象
    public static Date getExpireDate() {
        Instant now = Instant.now();
        Instant expireInstant = now.plusSeconds(EXPIRE_TIME_IN_HOUR * 60 * 60);
        return Date.from(expireInstant);
    }

}
